<template>
	<view class="timg">
		<image src="../../static/logbcg.png" mode=""></image>
		<view class="content">
			<image class="imgss" src="../../static/titimg.png" mode=""></image>
			<view class="uinput">
				<view class="uinput_it">
					<view class="uinput_flex">
						<image class="imgs" src="../../static/icon2.png" mode=""></image>
						<view class="ts">姓名/账号</view>
					</view>
					<view class="inputs">
						<input type="text" v-model="params.account" placeholder="请输入账号" placeholder-class="phsy" />
					</view>
				</view>
			
				<view class="uinput_it">
					<view class="uinput_flex">
						<image class="imgs" src="../../static/icon1.png" mode=""></image>
						<view class="ts">密码</view>
					</view>
					<view class="inputs" style="display: flex;align-items: center;">
						<input v-model="params.password" :password="showPwd" placeholder="请输入密码" placeholder-class="phsy" />
						<uni-icons :type="showPwd?'eye-slash':'eye'" size="24" @click="changeType"></uni-icons>
					</view>
				</view>
			</view>
			<view class="btn" :class="isall?'on':''" @click="goindex">
				登录
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getlogin
	} from '@/common/http.api.js'
	export default {
		data() {
			return {
				params:{
					account:'',
					password:'',
				},
				showPwd:true
			};
		},
		computed: {
			isall() {
				return this.params.account == '' || this.params.password == ''
			}
		},
		methods:{
			changeType() {
				this.showPwd = !this.showPwd
			},
			goindex(){
				if(!this.isall){
					uni.showLoading({
						title: '登录中...',
						mask: true
					})
					getlogin(this.params).then(res => {
						if (res.code == 1) {
							uni.setStorageSync('token', res.data.userinfo.token)
							res.data.userinfo.avatar = 'https://stone.heiwangke.net'+res.data.userinfo.avatar
							uni.setStorageSync('userinfo', res.data.userinfo)
							setTimeout(() => {
								uni.hideLoading()
								uni.reLaunch({
									url:'/pages/index/index'
								})
							}, 500)
					
						}
					})
				}else{
					uni.showToast({
						icon:'none',
						title:'请输入账号密码'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	.timg {
		width: 100%;
		height: 628rpx;
		position: relative;
		image {
			width: 100%;
			height: 628rpx;
		}
	}

	.content {
		top: 520rpx;
		position: absolute;
		width: 750rpx;
		background: #FFFFFF;
		border-radius: 60rpx 60rpx 0rpx 0rpx;
		.imgss{
			display: block;
			margin: 0 auto;
			width: 388rpx;
			height: 68rpx;
		}
	}
	
	.uinput {
		width: 670rpx;
		margin: 0 auto;
		.uinput_it {
			border-bottom: 1px solid #DFDFDF;
			margin-top: 72rpx;
			.uinput_flex {
				display: flex;
				align-items: center;
				.imgs {
					width: 38rpx;
					height: 38rpx;
					margin-right: 14rpx;
				}
				.ts {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 30rpx;
					color: #000000;
				}
			}
	
			.inputs {
				font-family: PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				padding: 34rpx 0rpx 19rpx 0rpx;
	
				input {
					flex: 1;
				}
	
				.eimage {
					width: 192rpx;
					height: 82rpx;
				}
			}
		}
	
	}
	.btn {
		width: 670rpx;
		height: 90rpx;
		background: #316FFC;
		border-radius: 45rpx;
		margin: 105rpx auto;
		font-family: PingFang SC;
		font-weight: 800;
		font-size: 32rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 90rpx;
	}
	.on {
		background: #316FFC;
		opacity: 0.5;
	}
</style>